          SUBROUTINE (OID,GEN,BR,PN,LDID,QSIGN,GROUP,MSG.FLAG,MSGS,RESPS)
** Version# 122 - 10/12/2011 - 04:10pm - EILEENM - main

 *** V103.01 Change - Add FULL Ver 107 - 11/23/2005 - JWITTENB - r8.0base

*** Subroutine - OE.GET.PN
*-------------------------------------------------------------------------*
*** Description:   This routine sets up the LD array, creates appropriate
*** comments, and sets up the kit information for the order.
*-------------------------------------------------------------------------*
*** OID         - The current order to add the product to.         (IN)
*** GEN         - The shipment (generation) to use for the item.   (IN)
*** BR          - The shipping branch of the order.                (IN)
*** PN          - The internal product ID to add to the order.     (IN)
*** LDID        - The line item id of the item on the order        (IN)
*** QSIGN       - The qty sign to use for this order               (IN)
*** GROUP       - The product group of the line item               (OUT)
*** MSG.FLAG    - Boolean, if this is true, then an action has     (OUT)
***             - been added to the MSGS array that requires user
***             - interaction.  Also, this update routine should
***             - be called again with the appropriate responces.
*** MSGS        - The actions array.                               [IN/OUT]
*** RESPS       - The responces array.                             [IN/OUT]
*-------------------------------------------------------------------------*
*** Common: This routine requires LD to be active
*-------------------------------------------------------------------------*

          STK.BR       = LED(2)<1,GEN,2>
          PRC.BR       = LED(2)<1,GEN,1>
          MODE         = OID[1,1]
          ERR          = 0
          PASS.ERR     = ERR.MSG
          ERR.MSG      = ''
          CMNTS        = ''
          REMOVE.1.CMNTS = NO
          REMOVE.EDI.CMNTS = NO

          *** Verify that the user's allowed to change the product
          IF PN#LD(1) AND LD(1)#'' THEN
             OE.CHECK.PN.CHANGE OID,GEN,LDID,MSG.FLAG,MSGS,RESPS
             IF MSG.FLAG THEN RETURN

             *** Set the update counter on the LD array
             LD(24)<1,3>     = 1
             OLD.LD(24)<1,3> = 1

             *** Clear out taxability check flag if changed pn
             LD(92)     = ''
             OLD.LD(92) = ''

             *** Clear out ld's that generate substitute comments
             LD(49)     = ''
             LD(50)     = ''
             OLD.LD(49) = ''
             OLD.LD(50) = ''

             *** Clear out serial numbers if pn changed
             LD(32) = ''
             LD(76) = ''
             LD(83) = ''
             LD(98) = ''

             *** Clear out the CPNs if pn changes
             LD(43) = ''

             *** Clear line item freight if pn changed
             LD(34) = ''
          END

          GET.ALL.PRD BR,PN,QSIGN,GROUP

          *** Verify that all of the required order information is on the
          *** product record.
          IF ERR#'' AND ERR#0 THEN
             MSG.ID    = '%51'
             MSG.ID<2> = PN[1,7]
             MSG.ID<3> = PRD(1)[1,30]
             ACTION.ADD.MSG MSGS,,YES,MSG.ID,,YES,,2,3

             PN = LD(1)
             *** If there was an old ld array (product)
             *** make sure to reset the common.
             IF LD(1)#'' THEN
                GET.ALL.PRD BR,LD(1),QSIGN,GROUP
             END

             ERR = 2
             IF NOT(PHANTOM.PROC) THEN RETURN
          END

          *** Miscellaneous items are not allowed to be adjusted
          IF (MODE='A' OR LED(110)<1,1>='R' OR (LED(110)<1,1>='T' AND MODE#'W')) AND PRD(3)=3 THEN
             MSG.FLAG = YES
             ACTION.ADD.MSG MSGS,,YES,'%61',,,,15,3
             ERR = 1
             IF NOT(PHANTOM.PROC) THEN RETURN
          END

          *** Kit items are not allowed to be adjusted.
          IF MODE='A' AND PRD(53)#'' AND NOT(PRD(106)) THEN
             MSG.FLAG = YES
             ACTION.ADD.MSG MSGS,,YES,'%62',,,,7,3
             ERR = 1
             RETURN
          END

          *** Kits cannot be used to establish a work order.
          IF MODE='W' AND PRD(53)#'' THEN
             ACTION.ADD.MSG MSGS,,YES,'%63',,,,7,3
             ERR = 1
             RETURN
          END

          IF PRD(3)=5 THEN
             *** If this authorization was already handled, continue
             *** adding the item onto the order.
             ACT.ID = 'OE.GET.PN.REV'

             LOCATE ACT.ID IN RESPS<1> SETTING RESP.POS ELSE
                MSG.FLAG = YES
                AUTH.KEY = "OE.PRODUCT.USE.REVIEW"
                ACTION.ADD.AUTH MSGS,ACT.ID,YES,'%64',,AUTH.KEY,,,OID
                IF NOT(PHANTOM.PROC) THEN RETURN
             END
          END

          IF PRD(91) AND MODE = 'S' THEN
             IF PHANTOM.PROC OR WEB.PROCESS$ THEN
                *** If it is a phantom proc or WOE, then we need to add
                *** a comment to LD(3) to warn the salesman that
                *** certification is required for this product since, in a
                *** phantom, we can't prompt for it.
                CERT.CMT = '*** Certification Required ***'
                LD(3)<1,1,-1> = CERT.CMT
             END ELSE
                ACT.ID = 'OE.GET.PN~PROD.CERT'
                LOCATE ACT.ID IN RESPS<1> SETTING RESP.POS THEN
                   CERT.OK = RESPS<2,RESP.POS,1>
                   IF NOT(CERT.OK) THEN
                      ERR = 1
                      RETURN
                   END
                END ELSE
                   *** If the user hasn't already authorized this, then
                   *** find all of the required certifications.
                   OE.CHECK.CERT OID,GEN,PRD(91),CERT.OK,PN,CERT.INFO
                   IF NOT(CERT.OK) THEN
                      MSG.FLAG = YES
                      ACTION.ADD.AUTH.CERT MSGS,ACT.ID,1,PRD(91),CERT.INFO
                      RETURN
                   END
                END
             END
          END

          *** Reset Pricing override flags AND stock allocation if Changed
          IF LD(1)#PN AND LD(1)#'' THEN
             *** If Previous product was not TEMP item then reset data..
             READV TST FROM PRDFILE,LD(1),3 ELSE TST = ''
             IF TST # 8 THEN
                LD(9)  = ''; LD(10) = 0;  LD(11) = ''; LD(27) = 0
                LD(28) = ''; LD(5)  = ''; LD(6)  = ''; LD(7)  = ''
                LD(55) = ''; LD(56) = ''; LD(57) = ''
             END
             *** Reset all of the lot item information for previous lots
             IF TST = 9 THEN
                LD(59) = ''; LD(60) = ''; LD(61) = ''; LD(62) = '';
                LD(63) = ''; LD(66) = ''; LD(67) = ''; LD(79) = '';
                LD(106) = 1
             END
          END

          IF LD(1) = "" THEN
             READV TST FROM PRDFILE,PN,3 ELSE TST = ""
             IF TST = 9 THEN
                CTRL.ID = "OE.LOT.TAG.DUPLICATES"
                READV ALLOW.TAG FROM CTRLFILE,CTRL.ID,1 ELSE ALLOW.TAG = ""
                LD(110) = ALLOW.TAG
             END
          END

          *** On remote EDI orders, any item not found in Eclipse will
          *** have the customer part number used for matching in the LD
          *** array and when typing over item not found with the correct
          *** product, we want to prompt user if they would like to cross
          *** reference the customer part number to this new product
          ACT.ID = 'OE.GET.PN~CUS.PN'
          LOCATE ACT.ID IN RESPS<1> SETTING RESP.POS THEN
             IF RESPS<2,RESP.POS,1> THEN
                CPN         = LD(104)<1,1>      ;* Cross ref storage
                LD(43)<1,1> = CPN               ;* Customer Part Number

                *** Write out entry to entity part number file
                CPN.ID      = LED(5)<1,GEN>:'~':CPN:'~~':PN
                READV REC FROM EPNFILE,CPN.ID,0 ELSE
                   WRITE '' ON EPNFILE,CPN.ID
                END
             END
             REMOVE.EDI.CMNTS = YES
          END ELSE
             IF LD(1) # PN AND LD(1) # '' THEN  ;* Typing over product
                IF LD(104)<1,1> AND NOT(LD(43)<1,1>) THEN
                   MSG.FLAG = YES
                   CPN      = LD(104)<1,1>
                   MSG.TEXT = '%209':AM:CPN
                   ACTION.ADD.PROMPT MSGS,ACT.ID,,MSG.TEXT,,,'YN',1,'Y'
                   RETURN
                END
             END
          END

          *** Remove the comments that are auto generated by the system
          *** so they are not duplicated.
          IF LD(3) # '' THEN GOSUB REMOVE.CMTS

          IF LD(1)#PN THEN
             *** If the prod was chgd, remove any replacement desc
             CMT     = ""
             RDES    = ""
             LOCATE "2" IN LD(2)<1> SETTING POS THEN
                LD(2) = DELETE(LD(2)<1>,POS)
                LD(3) = DELETE(LD(3)<1>,POS)
             END
             *** If changing pn's, or just adding a pn, need to evaluate
             *** it for Inv Acct Override.
             LD(114) = PRD(89)
             IF NOT(LD(114)) AND PLNE(24) THEN LD(114) = PLNE(24)
          END
          LD(1)  = PN
          IF NOT(PRD(106)) THEN
             LD(30) = PRD(52)
             LD(31) = PRD(53)
             LD(37) = PRD(85)
             LD(38) = PRD(86)
             LD(39) = PRD(87)
          END ELSE
             LD(30) = ''
             LD(31) = ''
             LD(37) = ''
             LD(38) = ''
             LD(39) = ''
          END

          *** Reset Dynamic Kit attributes
          FOR L = 71 TO 74
             LD(L) = ''
          NEXT L
          IF MODE # "P" AND NOT(CUSS(39)<1,1>) THEN
             IF (PRD.BR(19)+0)#0 THEN
                LD(34)<1,GEN> = ICONV(OCONV(PRD.BR(19),"MR2"),"MR9")
             END
          END

          *** Check taxable info... OE.TAXABLE.CHECK will handle dealing
          *** with the user interation, or lack-there-of.
          OE.TAXABLE.CHECK GEN,MSG.FLAG,MSGS,RESPS
          IF MSG.FLAG THEN RETURN

          *** Add Dflt nonstock comment to all Nonstocks
          IF MODE='S' THEN
             IF PRD(3)=2 OR PRD(3)=4 THEN
                CTRB.ID = 'NONSTOCK.COMMENT~':STK.BR
                READ CMNT FROM CTRBFILE,CTRB.ID ELSE CMNT=''
                NONSTOCK.COMMENTS.API CMNT,STK.BR
                IF CMNT#'' THEN
                   LOCATE "1" IN LD(2)<1> SETTING CPOS ELSE
                      CPOS = DCOUNT(LD(2)<1>,VM)+1
                      LD(2)<1,CPOS> = "1"
                   END
                   LOCATE CMNT IN LD(3)<1,CPOS> SETTING CLOC ELSE
                      LD(3)<1,CPOS,-1> = CMNT
                   END
                END
             END
          END

          *** Make sure that the correct entity pn is used
          IF LD(43)<1,1> # '' THEN
             PN.ID = PN:VM:LD(43)<1,1>
          END ELSE
             PN.ID = PN
          END

          *** Add the customer specific part #'s
          GOSUB CHECK.CUS.PN

          *** Add the Default Hazardous item comment
          READ COPY.HAZ FROM CTRLFILE,'COPY.HAZARD.COMMENT' ELSE COPY.HAZ = ''

          IF (MODE='S' OR (MODE = 'T' AND COPY.HAZ))  AND PRD(80)<1,3>#'' THEN
             READ CMNT FROM CTRLFILE,'HAZARD.COMMENT' ELSE CMNT = ''
             IF CMNT#'' THEN
                IF UNASSIGNED(CPOS) THEN
                   CPOS = DCOUNT(LD(2)<1>,VM)+1
                END
                LOCATE CMNT IN LD(3)<1,CPOS> SETTING CLOC ELSE
                   LD(3)<1,CPOS,-1> = CMNT
                END
             END
          END

          *** Store the PIL before the Ledger Detail is updated for Max
          *** Days Supply (MDS) calculations later on
          WBRS = STK.BR
          IF NOT(NO.NETWORK.PIL$) THEN
             GET.PCGID PCGID,PRD(18),PRD(12)
             WHSE.FOR.ME WHSE,STK.BR,PCGID
             WHSE.LIST WBRS,WHSE,PCGID
             WBRS = WBRS<1>
          END

          PIL.PN = LD(1)
          GET.PIL PIL,WBRS,PIL.PN,DATE()
          LD(69) = PIL

          LD(115) = PRD(138)<1>
          LD(116) = PRD(139)<1>
          LD(117) = PRD(138)<1,1>

FINISH:   RETURN
*-------------------------------------------------------------------------*
REMOVE.CMTS: * Make sure we don't get duplicate comments in the LD array
          OLD.PN = LD(1)
          IF OLD.PN = '' THEN RETURN
          OE.REMOVE.STD.CMTS OID,GEN,OLD.PN,PN,PRC.BR,REMOVE.EDI.CMNTS
          RETURN
*-------------------------------------------------------------------------*
CHECK.CUS.PN:*** customer specific part #s

          OE.CUS.PN.CMT.GET.ALL LED(1)<1,GEN>,LED(5)<1,GEN>,CUSS(66),PN.ID,CPNS,LOCS,CMTS,RELS,CCODES

          *** Setup the comment position to put comments in
          IF CMTS # '' THEN
             LOCATE "1" IN LD(2)<1> SETTING CPOS ELSE
                CPOS = DCOUNT(LD(2)<1>,VM)+1
                LD(2)<1,CPOS> = "1"
             END
          END

          LOCATE "OE.GET.PN~RDC" IN RESPS<1> SETTING NADA THEN
             * Special RDC senerio.
             RDC.LOC.CMT = YES

          END ELSE
             RDC.LOC.CMT = NO
          END

          *** CMT<1> = CUS.PN
          *** CMT<2> = LOCATION CODE
          *** CMT<3> = COMMENTS SPEC PNS.
          IF DCOUNT(CPNS,AM) > 1 THEN
             *** Setup the list of customer part #'s for the user to select
             *** from to add this line item.
             ACT.ID = 'OE.GET.PN~EPN'
             LOCATE ACT.ID IN RESPS<1> SETTING RESP.POS THEN
                EPOS  = RESPS<2,RESP.POS,1>
                CPN   = CPNS<EPOS>
                CMT   = RAISE(CMTS<EPOS>)
                REL   = RELS<EPOS>
                CCODE = CCODES<EPOS>
             END ELSE
                CPN.LST = ''
                CPN.IDS = ''
                CP.CT   = DCOUNT(CPNS,AM)
                FOR CPNN = 1 TO CP.CT
                   IF JAVA.PROC$ THEN
                      CPN.LST<1,-1> = CPNS<CPNN>[1,25]:SVM:LOCS<CPNN>[1,20]
                   END ELSE
                      CPN.LST<1,-1> = CPNS<CPNN>"L#25":' - ':LOCS<CPNN> "L#20"
                   END
                   CPN.IDS<1,-1> = CPNN
                NEXT CPNN

                MSG.FLAG = YES
                UT.OPEN.FILE 'PROMPTS',PROMPTFILE,ERR.MSG
                IF NOT(ERR.MSG) THEN
                   PRD.DESC = PRD(1)
                   CONVERT VM TO ' ' IN PRD.DESC
                   PRD.DESC = TRIM(PRD.DESC)

                   READV PROMPT.DESC FROM PROMPTFILE,'65',1 ELSE
                      PROMPT.DESC = ''
                   END
                   PROMPT.DESC := ' for ':PRD.DESC "L#25"
                END ELSE
                   PROMPT.DESC = '%65'
                END

                ACTION.ADD.TABLE MSGS,ACT.ID,CPN.LST,CPN.IDS,PROMPT.DESC
                RETURN TO FINISH
             END
          END ELSE
             CPN   = CPNS<1>
             CMT   = RAISE(CMTS)
             REL   = RAISE(RELS)
             CCODE = RAISE(CCODES)
          END

          *** If there was an entity specific part # add all of the info
          IF CPN THEN
             LD(43)<1,1> = CPN    ;* Customer Part Number

             *** Setup a position holder for where the next comment goes.
             CCT = DCOUNT(LD(3)<1,CPOS>,SVM)
             IF CMT<1> AND CMT<1>[1,1]#'@' THEN
                IF CMT<1>[1,1] = "!" THEN
                   *** if it is a replenishment pn get a part number that
                   *** the end customer is familiar with
                   TEMP.PN = ''
                   REPLEN.GET.LABEL.PN CMT<1>,TEMP.PN
                   IF TEMP.PN THEN
                      CCT += 1
                      LD(3)<1,CPOS,CCT> = 'Your # ':TEMP.PN
                   END
                END ELSE
                   CCT += 1
                   LD(3)<1,CPOS,CCT> = 'Your # ':CMT<1>
                END
             END

             * Only set the location comment & LD(43)<1,2> if we are not
             * working with a consignment billing.  The billing will pull
             * the location from location maintenance at the time of
             * invoicing the billing.
             IF CMT<2> AND LED(110)<1,1> # 'B' THEN
                *** Try to fill in cust ordered loc from the default first
                BEGIN CASE
                CASE LD(43)<1,2>
                   CCT += 1
                   LD(3)<1,CPOS,CCT> = 'Your Location : ':LD(43)<1,2>
                CASE NOT(RDC.LOC.CMT)
                   CCT += 1
                   LD(3)<1,CPOS,CCT> = 'Your Location : ':CMT<2>
                   LD(43)<1,2> = CMT<2> ;* Customer Defined Location
                END CASE
             END

             *** Add the customer pn comments.
             IF CMT<5> THEN
                *** Customer PN Comments can be multi-lined so add each ln
                C5.CT = DCOUNT(CMT<5>,VM)
                FOR CPN.LN = 1 TO C5.CT
                   CCT += 1
                   LD(3)<1,CPOS,CCT> = CMT<5,CPN.LN>
                NEXT CPN.LN
             END

             *** Add the Release Number
             IF REL THEN
                LD(36)<1,GEN,1> = REL<1>
             END

             *** Add the Cost Code
             IF CCODE THEN
                LD(103)<1,GEN> = CCODE
             END
          END

          RETURN
*-------------------------------------------------------------------------*
!EILEENM~10/12/11~16:10
